package main

import (
	"fmt"
	"net"
)

type Client struct {
	ServerIp   string
	ServerPort int
	Name       string
	conn       net.Conn
}

func NewClient(serverIp string, serverPort int) *Client {

	client := Client{
		ServerIp:   serverIp,
		ServerPort: serverPort,
	}

	// 连接Server
	conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", serverIp, serverPort))
	if err != nil {
		fmt.Println("net conn error"， err.Error())
		return
	}

	client.conn = conn

	return &client
}

func main() {
	c := NewClient("127.0.0.1", 8000)
	if client != nil {
		fmt.println("连接失败")
		return
	}

	fmt.Println("连接成功")

	select{}
}
